﻿using Microsoft.EntityFrameworkCore;
using Microsoft.VisualBasic;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace 乐观并发控制
{
    internal class MyDbContext : DbContext
    {
        public DbSet<House> Houses { get; set; }
        protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
        {
            //乐观并发控制：并发令牌
            optionsBuilder.UseMySql("server=localhost;user=root;password=SsS5olbXkXwAznMK;database=house",
            new MySqlServerVersion(new Version(8, 6, 20)));
            //乐观并发控制：RowVersion
            //string connStr = "Data Source=.;Initial Catalog=demo2;User ID=sa;Password=123456;TrustServerCertificate=True";
            //optionsBuilder.UseSqlServer(connStr);
            //optionsBuilder.LogTo(Console.WriteLine);
        }

        protected override void OnModelCreating(ModelBuilder modelBuilder)
        {
            base.OnModelCreating(modelBuilder);
            modelBuilder.ApplyConfigurationsFromAssembly(this.GetType().Assembly);
        }
    }
}
